//
//  ViewController.m
//  DaDaBao
//
//  Created by User on 15/7/22.
//  Copyright (c) 2015年 User. All rights reserved.
//
#import "AppDelegate.h"
#import "ViewController.h"
#import "WelcomeViewController.h"
#import "TotalViewController.h"

@interface ViewController ()<GestureDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    AppDelegate * delegate = [[UIApplication sharedApplication]delegate];
    
    if (delegate.sign != 100)
    {
        return;
    }
    
    NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
    NSString *versionNum =[infoDict objectForKey:@"CFBundleShortVersionString"];
    if([[NSUserDefaults standardUserDefaults]objectForKey:@"FirstLanding"])
    {
        if([[[NSUserDefaults standardUserDefaults]objectForKey:@"FirstLanding"] isEqualToString:versionNum])
        {
            //添加手势锁
            if ([[NSUserDefaults standardUserDefaults]objectForKey:@"GesturePsd"])
            {
                //如果存在这个手势密码，就进入这个界面
                SetGestureLockViewController * vc = [[SetGestureLockViewController alloc]initWithGestureType:verifyGestureLock];
                vc.delegate = self;
                [[[[[UIApplication sharedApplication] delegate] window] rootViewController]presentViewController:vc animated:FALSE completion:nil];
            }
            else
            {
                TotalViewController *totalViewCon = [[TotalViewController alloc]init];
                [self.navigationController pushViewController:totalViewCon animated:FALSE];
            }

        }
        else
        {
            [[NSUserDefaults standardUserDefaults]setObject:versionNum forKey:@"FirstLanding"];
            WelcomeViewController *welcomeViewCon = [[WelcomeViewController alloc]init];
            [self.navigationController pushViewController:welcomeViewCon animated:FALSE];
        }
    }
    else
    {
        [[NSUserDefaults standardUserDefaults]setObject:versionNum forKey:@"FirstLanding"];
        WelcomeViewController *welcomeViewCon = [[WelcomeViewController alloc]init];
        [self.navigationController pushViewController:welcomeViewCon animated:FALSE];
    }
}

- (void)enterTotal
{
    NSArray *navArray = self.navigationController.viewControllers;
    if(navArray.count <= 1)
    {
        TotalViewController *totalViewCon = [[TotalViewController alloc]init];
        [self.navigationController pushViewController:totalViewCon animated:FALSE];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
